<template>
  <div class="common-layout">
    <el-container>
      <el-aside width="200px">
        <div class="infos">
          <div class="top">
            <div class="leftimgs">
              <img :src="adminInfos.avater" alt="" />
            </div>
            <div class="rightInfos">
              <div class="name">
                <div>{{ adminInfos.userName }}</div>
                <div class="edit" @click="updateInfos">
                  <el-icon><Edit /></el-icon>
                </div>
              </div>
              <div class="state">
                <div class="state-box">
                  <span
                    class="state-box-circle"
                    style="background-color: #13ce66"
                  ></span>
                  <span>在线</span>
                </div>
                <div class="state-box">
                  <span
                    @click="gologin"
                    class="state-box-circle"
                    style="background-color: #ff4949"
                  ></span>
                  <span>退出</span>
                </div>
              </div>
            </div>
          </div>
          <div class="bottom">
            <el-icon><BellFilled /></el-icon>
            <div @click="goCenter" class="center">代办中心</div>
          </div>
        </div>
        <Aside></Aside>
      </el-aside>

      <el-container>
        <el-header>
          <div class="title" @click="welcome">后台管理系统</div>
        </el-header>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script lang="ts" setup>
import { useRouter } from "vue-router";
import Aside from "./Aside.vue";
import { useStore } from "@/stores/counter";
import { BellFilled } from "@element-plus/icons-vue";

const { adminInfos } = useStore();
const router = useRouter();
const gologin = () => {
  window.sessionStorage.clear();
  router.push("/alogin");
};
const welcome = () => {
  window.sessionStorage.removeItem("activePath");
  router.push("/admin/Welcome");
};
const goCenter = () => {
  router.push("/admin/adminCenter");
  window.sessionStorage.removeItem("activePath");
};

const updateInfos = () => {
  router.push('/admin/MyInfos')
}
</script>

<style scoped lang="less">
.common-layout {
  height: 100%;
  .el-container {
    height: 100%;
    .el-aside {
      background-color: #14b8a6;
    }
    .infos {
      display: flex;
      background-color: #14b8a6;
      flex-direction: column;
      .top {
        display: flex;
        align-items: center;
        padding: 20px 0 10px 10px;
        .leftimgs {
          width: 55px;
          height: 55px;
          margin-right: 8px;
          img {
            width: 100%;
            height: 100%;
            border-radius: 50px;
          }
        }
        .rightInfos {
          flex: 1;
          display: flex;
          flex-direction: column;
          .name {
            display: flex;
            justify-content: space-between;
            padding-right: 15px;
            align-items: center;
            .edit {
              color: #04336d;
            }
          }
          .state {
            display: flex;
            &-box {
              font-size: 10px;
              margin-right: 5px;
              display: flex;
              align-items: center;
              &-circle {
                width: 12px;
                height: 12px;
                border-radius: 50px;
                margin-right: 2px;
              }
            }
          }
        }
      }

      .bottom {
        color: #000;
        display: flex;
        align-items: center;
        background-color: #14b8a6;
        padding: 10px 20px;
        .center {
          margin-left: 8px;
        }
      }
      .bottom:hover {
        cursor: pointer;
      }
    }
    .logOut {
      width: 100%;
      .el-button {
        width: 100%;
      }
    }
    .el-header {
      padding: 0;
      line-height: 60px;
      text-align: center;
      border-bottom: 1px solid #000;
      background-color: #2dd4bf;
      .title {
        font-size: 26px;
        font-style: italic;
        text-shadow: 5px 5px 10px rgb(11, 140, 162);
      }
    }
  }
}
</style>
